package chuyentrung.racehorses;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;

import chuyentrung.racehorses.Horse.ColorHorse;
import chuyentrung.racehorses.framework.FileIO;

public class GamePreferences {
	public static int numPlayers = 2;
	public static ColorHorse[] typeHorse = null;
	
	public static boolean soundEnabled = true;
	public static boolean musicEnabled = true;
	
	public static int widthScreen = 320;
	public static int heightScreen = 480;
	
	public static void initPlayers() {
		typeHorse = null;
		typeHorse = new ColorHorse[numPlayers];		
	}
	
	public static void load(FileIO files){
		BufferedReader in = null;
		try {
			in = new BufferedReader(new InputStreamReader(files.readFile(".option")));			
		} catch (IOException e){			
		} finally {
			try {
				if (in != null)
					in.close();
			} catch (IOException e){}
		}
	}
	
	public static void save(FileIO files){
		BufferedWriter out = null;
		try {
			out = new BufferedWriter(new OutputStreamWriter(files.writeFile(".option")));			
		} catch(IOException e){			
		} finally {
			try {
				if (out != null){
					out.close();
				}
			} catch (IOException e){}
		}
	}

}
